home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- gui.h - description
- -------------------
- begin : 06.08.02
- copyright : (C) 2002 by AndrΘ Simon
- email : andre.simon1@gmx.de
- ***************************************************************************/
-
- /***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-
- #ifndef __gui_H__
- #define __gui_H__
-
- // For compilers that support precompilation, includes "wx/wx.h".
- #include "wx/wxprec.h"
-
- // Include wxWindows' headers
- #ifndef WX_PRECOMP
- #include <wx/wx.h>
- #endif
-
- #include <wx/dir.h>
- #include <wx/timer.h>
- #include <wx/dnd.h>
- #include <wx/filename.h>
- #include <wx/cmdline.h>
- #include <wx/utils.h>
- #include <wx/tipdlg.h>
- #include <wx/spinctrl.h>
- #include <wx/statline.h>
- #include <wx/combobox.h>
-
- #include <string>
- #include <stdlib.h>
- #include <windows.h>
- #include <iostream>
- #include <fstream>
- #include <set>
- #include <sstream>
- #include <vector>
-
- #include "version.h"
- #include "codegenerator.h"
- #include "configurationreader.h"
- #include "datadir.h"
- #include "enums.h"
- #include "platform_fs.h"
-
- #define MSG_INFO_TXT "Highlight for Windows %s\n(C) 2002-2005 AndrΘ Simon\
- <andre.simon1@gmx.de>\n\nArtistic Style Classes\n(C) 1998-2002 Tal Davidson\
- <davidsont@bigfoot.com>\n\nBuilt with WxWidgets %d.%d.%d\n\nTranslators:\n\n\
- %s\
- \nReleased under the terms of the GNU GPL license.\
- \n\nUpdates and source code: %s"
-
- #define CSS_DEFAULT_NAME "highlight.css"
-
- #define NUMBER_FORMATS 7
- #define NUMBER_ENCODINGS 15
-
-
- // The main Application
- class HighlightApp: public wxApp
- {
- public:
- virtual bool OnInit();
- };
-
-
- typedef map<string, string> ExtensionsMap;
-
-
- // The main Window
- class HighlightFrame : public wxFrame
- {
- public:
- HighlightFrame(const wxString &title);
-
- // Event handler (should *NOT* be virtual!)
- void OnQuit(wxCommandEvent &event);
- // void OnQuit2(wxCloseEvent &event);
- void OnClickButtonSource(wxCommandEvent &event);
- void OnClickButtonTargetDir(wxCommandEvent &event);
- void OnClickButtonClear(wxCommandEvent &event);
- void OnClickButtonRemSelection(wxCommandEvent &event);
- void OnClickButtonOpenStyleFile(wxCommandEvent &event);
- void OnClickButtonStart(wxCommandEvent &event);
- void OnHelp(wxCommandEvent &event);
- void OnAbout(wxCommandEvent &event);
- void OnLicense(wxCommandEvent &event);
- void OnChangelog(wxCommandEvent &event);
- void OnTips (wxCommandEvent &event);
- void OnCheckLanguage(wxCommandEvent &event);
- void OnStyleOutfileChanged (wxCommandEvent &event);
-
- void addInputFiles(const wxArrayString& inputFiles, const wxString& prefix);
- void showStartupTips(bool forceTips=false);
-
- void showPopupMenu(const wxPoint & pos);
-
- bool getFatalError(){ return fatalError; }
-
- private:
- bool fatalError;
- bool writePreferences();
- bool loadLanguage(const string &lang);
- bool loadFileExtensions();
- bool applyPreferences();
- void plausiChecks();
- void showTextFile(const wxString &file);
- string readFile(const string &path, bool keepNewLine=false);
-
- string getOutFileSuffix();
- string getFileType(const string& suffix);
- string getFileSuffix(const string& fileName);
-
- highlight::WrapMode getWrappingStyle();
- highlight::OutputType getOutputType();
-
- void SetStyleInLabel();
- void assignToolTip(wxWindow* widget, const char* tipName);
- void fillChoiceCtrl(wxChoice* choice, const wxString &dir, const wxString &ext);
- void checkStyleReferences(wxTextCtrl *styleCtrl, bool webOutput);
-
- ExtensionsMap extensions;
-
- string preferencesPath;
- wxString openFileDir, formatMsg, fileFilter;
- wxString outputFormats[NUMBER_FORMATS];
- wxString encodings[NUMBER_ENCODINGS];
-
- wxPanel *panel;
- wxButton *butSource, *butClearList, *butRemoveSelection;
- wxButton *butOutDir;
- wxButton *butStart;
- wxButton *butChooseStyleInfile;
- wxListBox *listBox ;
- wxChoice *themeChoice,
- *formatChoice;
- wxComboBox *encodingChoice;
- wxTextCtrl *outDir,
- *styleOutFileName,
- *styleInFileName;
- wxRadioBox *outputFormat;
- wxCheckBox *includeStyle,
- *fragment,
- *linenumbers,
- *attachAnchors,
- *reformatCode,
- *generateHtmlIndex,
- *wrapLines,
- *wrapLinesCautious,
- *replaceLatexQuotes,
- *lnFillZeroes,
- *writeToSourceDir,
- *useEncoding;
-
- wxSpinCtrl *tabWidth;
- wxStaticText *lblStyleOut, *lblColourTheme, *lblStyleIn, *lblOutDir, *lblTabWidth;
- wxMenu *menu1, *menu3, *menu2;
- wxMenuBar *MenuBar;
-
- bool showTips;
- int lastTip;
-
- wxGauge *progress;
- string language;
- ConfigurationReader *i18n, *prefConf;
-
- DataDir dataDir;
-
- // Any class wishing to process wxWindows events must use this macro
- DECLARE_EVENT_TABLE()
- };
- enum
- {
- PROGRAM_QUIT = wxID_HIGHEST+1,
- ID_MENU_OPENFILES,
- ID_BUTTON_OPENFILES,
- ID_BUTTON_OPEN_CSS_INFILE,
- ID_MENU_HELP,
- ID_MENU_ABOUT,
- ID_MENU_CHANGELOG,
- ID_MENU_LICENSE,
- ID_MENU_TIPS,
- ID_BUTTON_OUTDIR,
- ID_LISTBOX,
- ID_OUTDIRTEXT,
- ID_INCLUDECSS,
- ID_OUTPUTFORMAT,
- ID_START,
- ID_INCLUDELINENUMBERS,
- ID_FRAGMENT,
- ID_STYLE,
- ID_BUTTON_CLEAR,
- ID_PROGRESS,
- ID_THEMECHOICE,
- ID_ATTACHANCHORS,
- ID_CSS_INFILE,
- ID_CSS_OUTFILE,
- ID_REFORMATCODE,
- ID_FORMATCHOICE,
- ID_GENERATEINDEX,
- ID_WRAP,
- ID_WRAP_CAUTIOUS,
- ID_REPLACE_QUOTES,
- ID_TAB_WIDTH,
- ID_FILL_ZEROES,
- ID_WRITE_TO_SRCDIR,
- ID_PANEL,
- ID_BUTTON_REMOVE,
- ID_USE_ENCODING,
- ID_ENCODING_LIST,
- // This id is used to calculate menu ids at runtime:
- ID_MENU_LANGUAGE_DYN = wxID_HIGHEST + 100
- };
-
- BEGIN_EVENT_TABLE(HighlightFrame, wxFrame)
- EVT_MENU(PROGRAM_QUIT, HighlightFrame::OnQuit)
- EVT_CLOSE(HighlightFrame::OnQuit)
- EVT_MENU(ID_MENU_OPENFILES, HighlightFrame::OnClickButtonSource)
- EVT_MENU(ID_MENU_HELP, HighlightFrame::OnHelp)
- EVT_MENU(ID_MENU_ABOUT, HighlightFrame::OnAbout)
- EVT_MENU(ID_MENU_LICENSE, HighlightFrame::OnLicense)
- EVT_MENU(ID_MENU_CHANGELOG, HighlightFrame::OnChangelog)
- EVT_MENU(ID_MENU_TIPS, HighlightFrame::OnTips)
- EVT_BUTTON(ID_BUTTON_OPENFILES, HighlightFrame::OnClickButtonSource)
- EVT_BUTTON(ID_BUTTON_OUTDIR, HighlightFrame::OnClickButtonTargetDir)
- EVT_BUTTON(ID_START, HighlightFrame::OnClickButtonStart)
- EVT_BUTTON(ID_BUTTON_OPEN_CSS_INFILE, HighlightFrame::OnClickButtonOpenStyleFile)
- EVT_BUTTON(ID_BUTTON_CLEAR, HighlightFrame::OnClickButtonClear)
- EVT_BUTTON(ID_BUTTON_REMOVE , HighlightFrame::OnClickButtonRemSelection)
- EVT_CHECKBOX(ID_INCLUDECSS, HighlightFrame::plausiChecks)
-
- EVT_CHECKBOX(ID_INCLUDELINENUMBERS, HighlightFrame::plausiChecks)
- EVT_RADIOBOX(ID_OUTPUTFORMAT, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_REFORMATCODE, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_WRAP, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_WRAP_CAUTIOUS, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_FRAGMENT, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_WRITE_TO_SRCDIR, HighlightFrame::plausiChecks)
- EVT_CHECKBOX(ID_USE_ENCODING, HighlightFrame::plausiChecks)
- EVT_TEXT(ID_CSS_OUTFILE, HighlightFrame::OnStyleOutfileChanged)
- END_EVENT_TABLE()
-
- //BEGIN_EVENT_TABLE(MouseEvtHandler, wxEvtHandler)
- // EVT_RIGHT_DOWN(MouseEvtHandler::OnRightMouseDown)
- //END_EVENT_TABLE()
-
- IMPLEMENT_APP(HighlightApp)
-
-
- /* Drag and Drop Class*/
- class DropFiles: public wxFileDropTarget {
- public:
- DropFiles (HighlightFrame *frame) {m_frame = frame;}
- virtual bool OnDropFiles (wxCoord x, wxCoord y,
- const wxArrayString& filenames);
- private:
- HighlightFrame *m_frame;
- };
-
-
-
- #endif
-
-